home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cl_7_bug.zip / BUG_3.ERR < prev    next >
Text File  |  1992-10-10  |  7KB  |  219 lines

  1. ;    Static Name Aliases
  2. ;
  3.     TITLE   bug_3.c
  4.     .8087
  5. INCLUDELIB      LLIBCE
  6. INCLUDELIB    OLDNAMES.LIB
  7. BUG_3_TEXT    SEGMENT  WORD PUBLIC 'CODE'
  8. BUG_3_TEXT    ENDS
  9. _DATA    SEGMENT  WORD PUBLIC 'DATA'
  10. _DATA    ENDS
  11. CONST    SEGMENT  WORD PUBLIC 'CONST'
  12. CONST    ENDS
  13. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  14. _BSS    ENDS
  15. DGROUP    GROUP    CONST, _BSS, _DATA
  16.     ASSUME DS: DGROUP, SS: DGROUP
  17. PUBLIC  _s_width
  18. PUBLIC  _errmesg
  19. EXTRN    __acrtused:ABS
  20. EXTRN    _printf:FAR
  21. EXTRN    _puts:FAR
  22. EXTRN    _malloc:FAR
  23. EXTRN    _sprintf:FAR
  24. _DATA      SEGMENT
  25.     ORG    $+6
  26. $SG324    DB    'Formul',  84H, 'r: %s',  00H
  27. $SG325    DB    'Register: %s  %s',  00H
  28. $SG326    DB    'The following text should be: ''Register: reg(50)  Formul',  84H
  29.     DB    'r: form''',  00H
  30. $SG327    DB    'form',  00H
  31. $SG328    DB    'reg',  00H
  32. $SG329    DB    00H
  33. $SG340    DB    '%s(%d)',  00H
  34.     ORG    $-119
  35. _s_width    DW    050H
  36. _errmesg    DD    00H
  37. _DATA      ENDS
  38. BUG_3_TEXT      SEGMENT
  39.     ASSUME    CS: BUG_3_TEXT
  40.     PUBLIC    _main
  41. _main    PROC FAR
  42. ;|*** /*
  43. ;|***   Test if intrisinic strlen with doesn't work
  44. ;|***   This code works if errmesg isn't near.
  45. ;|***  */
  46. ;|*** 
  47. ;|*** #include <stdio.h>
  48. ;|*** #include <malloc.h>
  49. ;|*** 
  50. ;|*** void print_name(int textnr,char * name,char * formname);
  51. ;|*** void pack_filename(char * to,char * from,int length);
  52. ;|*** 
  53. ;|*** #define ER(X) errmesg[(X)-3000]
  54. ;|*** 
  55. ;|*** int  s_width=80;
  56. ;|*** extern char ** near errmesg=0;
  57. ;|*** 
  58. ;|*** int main(int argc,char *argv[])
  59. ;|*** {
  60. ; Line 18
  61. ;    argv = 8
  62. ;    argc = 6
  63. ;|***   errmesg=(char**) malloc(sizeof(char *)*200);
  64. ; Line 19
  65.     *** 000000    b8 20 03         mov    ax,800    ;0320H
  66.     *** 000003    50             push    ax
  67.     *** 000004    9a 00 00 00 00         call    FAR PTR _malloc
  68.     *** 000009    83 c4 02         add    sp,2
  69.     *** 00000c    a3 02 00         mov    WORD PTR _errmesg,ax
  70.     *** 00000f    89 16 04 00         mov    WORD PTR _errmesg+2,dx
  71. ;|***   errmesg[118]="Formulär: %s";
  72. ; Line 20
  73.     *** 000013    c4 1e 02 00         les    bx,DWORD PTR _errmesg
  74.     *** 000017    26 c7 87 d8 01 06 00     mov    WORD PTR es:[bx+472],OFFSET DGROUP:$SG324
  75.     *** 00001e    26 8c 9f da 01         mov    WORD PTR es:[bx+474],ds
  76. ;|***   errmesg[123]="Register: %s  %s";
  77. ; Line 21
  78.     *** 000023    c4 1e 02 00         les    bx,DWORD PTR _errmesg
  79.     *** 000027    26 c7 87 ec 01 13 00     mov    WORD PTR es:[bx+492],OFFSET DGROUP:$SG325
  80.     *** 00002e    26 8c 9f ee 01         mov    WORD PTR es:[bx+494],ds
  81. ;|*** 
  82. ;|***   puts("The following text should be: 'Register: reg(50)  Formulär: form'");
  83. ; Line 23
  84.     *** 000033    b8 24 00         mov    ax,OFFSET DGROUP:$SG326
  85.     *** 000036    1e             push    ds
  86.     *** 000037    50             push    ax
  87.     *** 000038    9a 00 00 00 00         call    FAR PTR _puts
  88.     *** 00003d    83 c4 04         add    sp,4
  89. ;|***   print_name(3123,"reg","form");
  90. ; Line 24
  91.     *** 000040    b8 66 00         mov    ax,OFFSET DGROUP:$SG327
  92.     *** 000043    1e             push    ds
  93.     *** 000044    50             push    ax
  94.     *** 000045    b8 6b 00         mov    ax,OFFSET DGROUP:$SG328
  95.     *** 000048    1e             push    ds
  96.     *** 000049    50             push    ax
  97.     *** 00004a    b8 33 0c         mov    ax,3123    ;0c33H
  98.     *** 00004d    50             push    ax
  99.     *** 00004e    9a 00 00 00 00         call    FAR PTR _print_name
  100.     *** 000053    83 c4 0a         add    sp,10    ;000aH
  101. ;|***   puts("");
  102. ; Line 25
  103.     *** 000056    b8 6f 00         mov    ax,OFFSET DGROUP:$SG329
  104.     *** 000059    1e             push    ds
  105.     *** 00005a    50             push    ax
  106.     *** 00005b    9a 00 00 00 00         call    FAR PTR _puts
  107.     *** 000060    83 c4 04         add    sp,4
  108. ;|***   return 0;
  109. ; Line 26
  110.     *** 000063    33 c0             xor    ax,ax
  111. ;|*** }
  112. ; Line 27
  113.     *** 000065    cb             ret    
  114.  
  115. _main    ENDP
  116.     PUBLIC    _print_name
  117. _print_name    PROC FAR
  118. ;|*** 
  119. ;|*** void print_name(int textnr,char * name,char * formname)
  120. ;|*** {
  121. ; Line 30
  122.     *** 000066    55             push    bp
  123.     *** 000067    8b ec             mov    bp,sp
  124.     *** 000069    81 ec a4 00         sub    sp,164    ;00a4H
  125.     *** 00006d    57             push    di
  126.     *** 00006e    56             push    si
  127. ;    textnr = 6
  128. ;    name = 8
  129. ;    formname = 12
  130. ;    register si = length
  131. ;    buff2 = -82
  132. ;    b_name = -164
  133. ;|***   unsigned int length;
  134. ;|***   char buff2[81],b_name[81];
  135. ;|*** 
  136. ;|***   sprintf(buff2,ER(3118),formname);
  137. ; Line 34
  138.     *** 00006f    ff 76 0e         push    WORD PTR [bp+14]
  139.     *** 000072    ff 76 0c         push    WORD PTR [bp+12]    ;formname
  140.     *** 000075    c4 1e 02 00         les    bx,DWORD PTR _errmesg
  141.     *** 000079    26 ff b7 da 01         push    WORD PTR es:[bx+474]
  142.     *** 00007e    26 ff b7 d8 01         push    WORD PTR es:[bx+472]
  143.     *** 000083    8d 46 ae         lea    ax,WORD PTR [bp-82]    ;buff2
  144.     *** 000086    16             push    ss
  145.     *** 000087    50             push    ax
  146.     *** 000088    9a 00 00 00 00         call    FAR PTR _sprintf
  147.     *** 00008d    83 c4 0c         add    sp,12    ;000cH
  148. ;|***   length=strlen(buff2);
  149. ; Line 35
  150.     *** 000090    8d 7e ae         lea    di,WORD PTR [bp-82]    ;buff2
  151.     *** 000093    8c d0             mov    ax,ss
  152.     *** 000095    8e c0             mov    es,ax
  153.     *** 000097    b9 ff ff         mov    cx,-1    ;ffffH
  154.     *** 00009a    33 c0             xor    ax,ax
  155.     *** 00009c    f2             repnz
  156.     *** 00009d    ae             scasb
  157.     *** 00009e    f7 d1             not    cx
  158.     *** 0000a0    49             dec    cx
  159.     *** 0000a1    8b f1             mov    si,cx
  160. ;|***   sprintf(b_name,"%s(%d)",name,s_width-strlen(ER(textnr))-length);
  161. ; Line 36
  162.     *** 0000a3    8b 7e 06         mov    di,WORD PTR [bp+6]    ;textnr
  163.     *** 0000a6    d1 e7             shl    di,1
  164.     *** 0000a8    d1 e7             shl    di,1
  165.     *** 0000aa    c4 1e 02 00         les    bx,DWORD PTR _errmesg
  166.     *** 0000ae    26 8b 81 20 d1         mov    ax,WORD PTR es:[bx-12000][di]
  167.     *** 0000b3    26 8b 91 22 d1         mov    dx,WORD PTR es:[bx-11998][di]
  168.     *** 0000b8    8b f8             mov    di,ax
  169.     *** 0000ba    8e c2             mov    es,dx
  170.     *** 0000bc    b9 ff ff         mov    cx,-1    ;ffffH
  171.     *** 0000bf    33 c0             xor    ax,ax
  172.     *** 0000c1    f2             repnz
  173.     *** 0000c2    ae             scasb
  174.     *** 0000c3    f7 d1             not    cx
  175.     *** 0000c5    49             dec    cx
  176.     *** 0000c6    2b 0e 00 00         sub    cx,WORD PTR _s_width
  177.     *** 0000ca    f7 d9             neg    cx
  178.     *** 0000cc    2b ce             sub    cx,si
  179.     *** 0000ce    51             push    cx
  180.     *** 0000cf    ff 76 0a         push    WORD PTR [bp+10]
  181.     *** 0000d2    ff 76 08         push    WORD PTR [bp+8]    ;name
  182.     *** 0000d5    b9 70 00         mov    cx,OFFSET DGROUP:$SG340
  183.     *** 0000d8    1e             push    ds
  184.     *** 0000d9    51             push    cx
  185.     *** 0000da    8d 8e 5c ff         lea    cx,WORD PTR [bp-164]    ;b_name
  186.     *** 0000de    16             push    ss
  187.     *** 0000df    51             push    cx
  188.     *** 0000e0    8b f0             mov    si,ax
  189. ; MONTY: Ax is zero here, CL has forgotten that ax was used in strlen.
  190.     *** 0000e2    9a 00 00 00 00         call    FAR PTR _sprintf
  191.     *** 0000e7    83 c4 0e         add    sp,14    ;000eH
  192. ;|***   printf(ER(textnr),b_name,buff2);
  193. ; Line 37
  194.     *** 0000ea    8d 46 ae         lea    ax,WORD PTR [bp-82]    ;buff2
  195.     *** 0000ed    16             push    ss
  196.     *** 0000ee    50             push    ax
  197.     *** 0000ef    8d 86 5c ff         lea    ax,WORD PTR [bp-164]    ;b_name
  198.     *** 0000f3    16             push    ss
  199.     *** 0000f4    50             push    ax
  200.     *** 0000f5    c4 1e 02 00         les    bx,DWORD PTR _errmesg
  201. ; MONTY: And here we uses our new null-pointer
  202.     *** 0000f9    26 ff b0 22 d1         push    WORD PTR es:[bx-11998][si]
  203.     *** 0000fe    26 ff b0 20 d1         push    WORD PTR es:[bx-12000][si]
  204.     *** 000103    9a 00 00 00 00         call    FAR PTR _printf
  205.     *** 000108    83 c4 0c         add    sp,12    ;000cH
  206. ;|***   return;
  207. ;|*** } /* print_name */
  208. ; Line 39
  209.     *** 00010b    5e             pop    si
  210.     *** 00010c    5f             pop    di
  211.     *** 00010d    8b e5             mov    sp,bp
  212.     *** 00010f    5d             pop    bp
  213.     *** 000110    cb             ret    
  214.     *** 000111    90             nop    
  215.  
  216. _print_name    ENDP
  217. BUG_3_TEXT    ENDS
  218. END
  219.